#include "Server.hpp"
#include"Session.hpp"
string getmessage(string &messages)
{

    // 接收反序列字符串messages
    string content;
    Request request;
    Response response;
    Calaculate calaculate;
    string response_str;
    bool n = Decode(messages, &content);
    if (n == false)
        response.SetErrorCode(4); // 解码失败设置错误码4
    else
    {
        n = request.Deserialize(content); // 反序列化request
        if (n == false)
            response.SetErrorCode(5); // 反序列化失败设置错误码5
        else
        {
            calaculate.Calculator(request, response);
            // 序列化response
        }
    }
    response.Serialize(response_str);
    // 返回序列化后的response字符串
    return response_str;
}




int main()
{
    Session(1,1);
    //session.CreatSession(true,true); //创建会话

    // 实例化TcpServer
    tast_t task=getmessage;
    unique_ptr<TcpServer> ptr = make_unique<TcpServer>(task);
    ptr->Init();
    ptr->Start();
    return 0;
}